﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using XNADota.Terrain;

namespace XNADota.GamePlay
{
    public class GameplayWorld
    {
        private PlayerCommander _Player;
        private PathManager _PathManager;
        private ObjectsManager _ObjectsManager;
        private GamePhaseManager _GamePhaseManager;

        public void CreateLogicMembers(Game game, Landscape Landscape)
        {
            GameplayWorld.Instance.PathManager = new PathManager(game, Landscape.LangscapeConfig);
            GameplayWorld.Instance.ObjectsManager = new ObjectsManager(game, Landscape.LangscapeConfig);
        }

        public PathManager PathManager
        {
            set { _PathManager = value; }
            get { return _PathManager; }
        }

        public ObjectsManager ObjectsManager
        {
            set { _ObjectsManager = value; }
            get { return _ObjectsManager; }
        }

        public void Initialize(Game game)
        {
            _Player = new PlayerCommander(game);
        }

        public void PrepareAll()
        {
            _PathManager.GenerateHeightData();
            _GamePhaseManager = new GamePhaseManager();
        }

        public void Update(GameTime gameTime)
        {
            _GamePhaseManager.Update(gameTime);
            _Player.Update(gameTime);
        }

        public void UpdateAfterIntegration()
        {
            _GamePhaseManager.UpdateAfterIntegration();
        }

        public void Draw(GameTime gameTime)
        {
            _GamePhaseManager.Draw(gameTime);
            _Player.Draw(gameTime);
        }

        #region Singleton
        private static GameplayWorld _Instance = new GameplayWorld();
        private GameplayWorld() { }
        public static GameplayWorld Instance
        {
            get { return _Instance; }
        }
        #endregion
    }
}
